package com.aode.common.bean.response;

import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;
import android.widget.ImageView;

import androidx.databinding.BaseObservable;
import androidx.databinding.Bindable;
import androidx.databinding.BindingAdapter;

import com.aode.common.url.UrlGather;
import com.bumptech.glide.Glide;

public class User extends BaseObservable implements Parcelable {
    private static final long serialVersionUID = 1L;

    /**
     * 用户ID
     */
    private Integer userId;
    /**
     * 用户名
     */
    private String userName;
    /**
     * 用户密码
     */
    private String userPassword;
    /**
     * 用户昵称
     */
    private String userNickname;
    /**
     * 用户年龄
     */
    private Integer userAge;
    /**
     * 用户性别
     */
    private String userSex;
    /**
     * 用户地址
     */
    private String userPlace;
    /**
     * 用户头像
     */
    private String userAvatar;
    @BindingAdapter({"userimage"})
    public static void loadImage(ImageView imageView, String imageUrl){
        Glide.with(imageView.getContext()).load(UrlGather.BASE_URL+imageUrl).into(imageView);
    }
    /**
     * 用户金额
     */
    private Double userAccount;
    /**
     * 用户爱好
     */
    private String userHobby;
    /**
     * 用户职业
     */
    private String userProfession;
    /**
     * 用户个性签名
     */
    private String userSignature;
    /**
     * 酷狗ID
     */
    private String userKu;
    /**
     * 用户出生日期
     */
    private String userBirthday;

    protected User(Parcel in) {
        if (in.readByte() == 0) {
            userId = null;
        } else {
            userId = in.readInt();
        }
        userName = in.readString();
        userPassword = in.readString();
        userNickname = in.readString();
        if (in.readByte() == 0) {
            userAge = null;
        } else {
            userAge = in.readInt();
        }
        userSex = in.readString();
        userPlace = in.readString();
        userAvatar = in.readString();
        if (in.readByte() == 0) {
            userAccount = null;
        } else {
            userAccount = in.readDouble();
        }
        userHobby = in.readString();
        userProfession = in.readString();
        userSignature = in.readString();
        userKu = in.readString();
        userBirthday = in.readString();
    }

    public static final Creator<User> CREATOR = new Creator<User>() {
        @Override
        public User createFromParcel(Parcel in) {
            return new User(in);
        }

        @Override
        public User[] newArray(int size) {
            return new User[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        if (userId == null) {
            dest.writeByte((byte) 0);
        } else {
            dest.writeByte((byte) 1);
            dest.writeInt(userId);
        }
        dest.writeString(userName);
        dest.writeString(userPassword);
        dest.writeString(userNickname);
        if (userAge == null) {
            dest.writeByte((byte) 0);
        } else {
            dest.writeByte((byte) 1);
            dest.writeInt(userAge);
        }
        dest.writeString(userSex);
        dest.writeString(userPlace);
        dest.writeString(userAvatar);
        if (userAccount == null) {
            dest.writeByte((byte) 0);
        } else {
            dest.writeByte((byte) 1);
            dest.writeDouble(userAccount);
        }
        dest.writeString(userHobby);
        dest.writeString(userProfession);
        dest.writeString(userSignature);
        dest.writeString(userKu);
        dest.writeString(userBirthday);
    }

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }
    @Bindable
    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUserPassword() {
        return userPassword;
    }

    public void setUserPassword(String userPassword) {
        this.userPassword = userPassword;
    }

    public String getUserNickname() {
        return userNickname;
    }

    public void setUserNickname(String userNickname) {
        this.userNickname = userNickname;
    }

    public Integer getUserAge() {
        return userAge;
    }

    public void setUserAge(Integer userAge) {
        this.userAge = userAge;
    }

    public String getUserSex() {
        return userSex;
    }

    public void setUserSex(String userSex) {
        this.userSex = userSex;
    }

    public String getUserPlace() {
        return userPlace;
    }

    public void setUserPlace(String userPlace) {
        this.userPlace = userPlace;
    }
    @Bindable
    public String getUserAvatar() {
        return userAvatar;
    }

    public void setUserAvatar(String userAvatar) {
        this.userAvatar = userAvatar;
    }

    public Double getUserAccount() {
        return userAccount;
    }

    public void setUserAccount(Double userAccount) {
        this.userAccount = userAccount;
    }

    public String getUserHobby() {
        return userHobby;
    }

    public void setUserHobby(String userHobby) {
        this.userHobby = userHobby;
    }

    public String getUserProfession() {
        return userProfession;
    }

    public void setUserProfession(String userProfession) {
        this.userProfession = userProfession;
    }

    public String getUserSignature() {
        return userSignature;
    }

    public void setUserSignature(String userSignature) {
        this.userSignature = userSignature;
    }
    @Bindable
    public String getUserKu() {
        return userKu;
    }

    public void setUserKu(String userKu) {
        this.userKu = userKu;
    }

    public String getUserBirthday() {
        return userBirthday;
    }

    public void setUserBirthday(String userBirthday) {
        this.userBirthday = userBirthday;
    }

    public static Creator<User> getCREATOR() {
        return CREATOR;
    }
}
